from agent import BackgroundAgent
from a2a_handler import BackgroundAgentHandler
from a2a.server.apps import A2AStarletteApplication
from a2a.types import AgentCapabilities, AgentCard, AgentSkill


if __name__ == '__main__':

    # 1. 创建agent和请求handler
    agent = BackgroundAgent()
    request_handler = BackgroundAgentHandler(agent)

    # 2. A2AStarletteApplication构建A2A服务器
    server = A2AStarletteApplication(
        agent_card=agent.get_agent_card(), http_handler=request_handler
    )

    # 3. 使用 Uvicorn 启动服务器，监听请求
    import uvicorn
    uvicorn.run(server.build(), host='0.0.0.0', port=9999)